/*
============================================================================
FileName	:	XQChatRoster.h
Author		:	liyake
Website		:	http://www.liyake.com
Create Data	:	2012-03-14 16:27
Change Data	:	2012-03-14 16:27
Detail		:	just like a struct
============================================================================
*/
#ifndef _XQCHAT_ROSTER_H_
#define _XQCHAT_ROSTER_H_
#include <QtCore>
#include <QXmppPresence.h>

namespace XQChat
{
	class CXQChatClient;
	class CXQChatRoster : public QObject
	{
		Q_OBJECT
	public:
		enum SubscriptionType
		{
			None = 0,   ///< the user does not have a subscription to the
			///< contact's presence information, and the contact does
			///< not have a subscription to the user's presence information
			From = 1,   ///< the contact has a subscription to the user's presence information,
			///< but the user does not have a subscription to the contact's presence information
			To = 2,     ///< the user has a subscription to the contact's presence information,
			///< but the contact does not have a subscription to the user's presence information
			Both = 3,   ///< both the user and the contact have subscriptions to each
			///< other's presence information
			Remove = 4, ///< to delete a roster item
			NotSet = 8  ///< the subscription state was not specified
		};

	public:
		CXQChatRoster(const QString& jid,XQChat::CXQChatClient* pClient);
		~CXQChatRoster(void);

	public:
		QString getFullJid() const;			//include the client type.
		QString getBareJid() const;
		QSet<QString> getGroups() const;
		QString getName() const;
		SubscriptionType getSubscriptionType() const;
		QString getSubscriptionStatus() const;
		QXmppPresence getPresence() const;
		QXmppPresence getPresence(const QString& resource) const;
		QStringList getResources() const;
		CXQChatClient* getXQChatClient() const {return m_pClient;}
		QString getHeaderIcon() const;
		QString getHeaderUrl() const { return m_qsHeaderUrl; }

		void setBareJid(const QString& jid);
		void setGroups(const QSet<QString>& groups);
		void setName(const QString& name);
		void setSubscriptionType (const SubscriptionType& type);
		void setSubscriptionStatus(const QString& status);
		void setPresence(const QString& resource, const QXmppPresence& presence);
		void setHeaderIcon(const QString& icon);
		void setHeaderUrl(const QString& url);

signals:
		void headerIconChanged();

	protected:
		QString m_qsBareJid;
		SubscriptionType m_iSubscriptionType;
		QString m_qsName;
		// can be subscribe/unsubscribe (attribute "ask")
		QString m_qsSubscriptionStatus;
		QString m_qsHeaderIcon;				//local in the file.
		QString m_qsHeaderUrl;				//header'url in the web.
		QSet<QString> m_setGroups;
		QMap<QString, QXmppPresence> m_mapPresences; //QString:resource.
		CXQChatClient* m_pClient;
	};
}

#endif	//_XQCHAT_ROSTER_H_